<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>自定义属性</title>
    <script type="text/javascript" src="../js/jquery-3.4.1.min.js"></script>
    <script>
        $(function(){
            $("#btn").click(function(){
                console.log($(this).attr("a"));
            });
            $("#delete").click(function(){
                console.log("data-id:"+$(this).attr("data-id"))
            });
        })
    </script>
</head>
<body>
<!--
    在实际开发中,对于自定义属性不允许随便取名字
    要求自定义属性的命名格式为:data-xxx
-->
<button id="btn" a="b">测试</button><br>
<a href="javascript:;" data-id="2" id="delete">删除</a>
</body>
</html>